import axios from 'axios'
// 设置基准路径
const baseUrl = 'http://127.0.0.1:3000/'
axios.defaults.baseURL = baseUrl

// 分类模块
// =>一级分类
export const firstCategory = () => {
  return axios.get('/category/queryTopCategory').then(res => {
    return res.data
  })
}
// =>二级分类
export const scoendCategory = (id) => {
  return axios.get('/category/querySecondCategory', {params: {id: id}}).then(res => {
    return res.data
  })
}
// 搜索产品
export const searchGoods = (options) => {
  return axios.get('/product/queryProduct', {params: options}).then(res => {
    return res.data
  })
}
// =>商品详情
export const productDetail = (id) => {
  return axios.get('/product/queryProductDetail', {params: {id: id}}).then(res => {
    return res.data
  })
}
// 注册用户
export const register = (options) => {
  return axios.post('/user/register', options).then(res => {
    return res.data
  })
}
// 获取注册验证码
export const vcode = () => {
  return axios.get('/user/vCode').then(res => {
    return res.data
  })
}
